﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Medianamik.Core.Security;

namespace Medianamik.Core.Security
{
    public class Permission
    {

        #region Fields
        

            
        #endregion

        #region .ctors

        public Permission(Guid securedObjectId, Guid groupId, SecurityLevels securityLevel,
            PermissionType permissionType) //, bool mustApplyToChildren
        {
            SecuredObjectId = securedObjectId;
            GroupId = groupId;
            SecurityLevel = securityLevel;
            PermissionType = permissionType;
            //MustApplyToChildren = mustApplyToChildren;
        }

        #endregion

        #region Properties

        public SecurityLevels SecurityLevel {get; set;}

        public Guid SecuredObjectId{get; internal set;}

        private Guid groupId;
        public Guid GroupId
        {
            get
            {
                return groupId;
            }
            internal set
            {
                if (value.Equals(MedianamikGroups.SuperAdmins))
                    throw new InvalidOperationException("Cannot restrict access for SuperAdmins.");

                groupId = value;
            }
        }

        public PermissionType PermissionType { get; internal set; }

        //internal bool MustApplyToChildren { get; set; }
        
        #endregion

    }
}
